#include <bits/stdc++.h>
using namespace std;

// 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2
// 注意权重是相乘 不是相加
int main()
{
    int n;
    cin >> n;
    int weight[17] = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
    char check[11] = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
    vector<string> disabled;
    for (int i = 0; i < n; i++)
    {
        string str;
        cin >> str;
        int xd = 0;
        // 加权
        unsigned int j = 0;
        for (; j < str.length() - 1; j++)
        {
            if (str[j] >= '0' && str[j] <= '9')
            {
                xd += (str[j] - '0') * weight[j];
            }
            else
            {
                disabled.push_back(str);
                break;
            }
        }

        if (j >= str.length() - 1)
        {
            // 取余
            int mod = xd % 11;
            char ch = check[mod];
            if (str[str.length() - 1] != ch)
                disabled.push_back(str);
        }
    }
    if (disabled.size() == 0)
        cout << "All passed" << endl;
    else
    {
        for (auto &v : disabled)
        {
            cout << v << endl;
        }
    }
    return 0;
}